//
//  HHPersonDataCell.m
//  BXlive
//
//  Created by bxlive on 2018/4/27.
//  Copyright © 2018年 cat. All rights reserved.
//

#import "HHPersonDataCell.h"
#import <SLDeveloperTools/SLDeveloperTools.h>
#import <Masonry/Masonry.h>

@interface HHPersonDataCell ()

@end

@implementation HHPersonDataCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.backgroundColor = [UIColor clearColor];
        [self createUI];
    }
    return self;
}

- (void)createUI{
    
    self.titleLabel = [UILabel initWithFrame:CGRectZero size:14 color:sl_textSubColors alignment:NSTextAlignmentLeft lines:1];
    self.titleLabel.font = SLPFFont(16);
    [self.contentView addSubview:self.titleLabel];
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(__ScaleWidth(12));
        make.height.mas_equalTo(__ScaleWidth(22));
        make.centerY.mas_equalTo(0);
        make.width.mas_greaterThanOrEqualTo(__ScaleWidth(80));
    }];
    
    self.nextImageView = [[UIImageView alloc]initWithFrame:CGRectZero];
    self.nextImageView.image = [UIImage imageNamed:@"箭头下一步"];
    [self.contentView addSubview:self.nextImageView];
    [self.nextImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(8);
        make.height.mas_equalTo(12);
        make.centerY.mas_equalTo(0);
        make.right.mas_equalTo(-__ScaleWidth(12));
    }];
    
    self.contentLabel = [UILabel initWithFrame:CGRectZero size:16 color:sl_textColors alignment:NSTextAlignmentRight lines:1];
    self.contentLabel.font  = SLBFont(16);
    [self.contentView addSubview:self.contentLabel];
    [self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.mas_equalTo(0);
        make.left.mas_equalTo(self.titleLabel.mas_right).offset(5);
        make.right.mas_equalTo(self.nextImageView.mas_left).offset(-5);
    }];
    
//    self.fengeView = [[UIView alloc]initWithFrame:CGRectZero];
//    self.fengeView.backgroundColor = LineNormalColor;
//
//    [self.contentView addSubview:self.fengeView];
//    [self.fengeView mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.height.mas_equalTo(.5);
//        make.bottom.mas_equalTo(0);
//        make.left.mas_equalTo(15);
//        make.right.mas_equalTo(0);
//    }];
}

- (void)setTitle:(NSString *)title subTitle:(NSString *)subTitle color:(UIColor *)color type:(NSInteger)type isLast:(BOOL)isLast {
    self.titleLabel.text = title;
    self.contentLabel.text = subTitle;
    if (color) {
        self.contentLabel.textColor = color;
    }    
    self.nextImageView.hidden = !type;
    
    if (type) {
        [self.contentLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.top.bottom.mas_equalTo(0);
            make.left.mas_equalTo(self.titleLabel.mas_right).offset(5);
            make.right.mas_equalTo(self.nextImageView.mas_left).offset(-5);
        }];
    } else {
        [self.contentLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.top.bottom.mas_equalTo(0);
            make.left.mas_equalTo(self.titleLabel.mas_right).offset(5);
            make.right.mas_equalTo(-15);
        }];
    }
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
